﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using NDbUnit.Core;
using NDbUnit.Core.SqlClient;
using NUnit.Framework;

namespace EasySite.Tests
{
    [TestFixture]
    public class DbUnitTestBase : UnitTestBase
    {
        private INDbUnitTest _database;
        private readonly string _connectionString;

        public DbUnitTestBase()
        {
            const string configName = "EasySite.Tests.Properties.Settings.EasySiteConnectionString";
            _connectionString = ConfigurationManager.ConnectionStrings[configName].ConnectionString;
        }

        [TestFixtureSetUp]
        public void TestSetupFixture()
        {
            _database = new SqlDbUnitTest(_connectionString);
            _database.ReadXmlSchema("../../TestData/EasySiteTest.xsd");
            _database.ReadXml("../../TestData/EasySiteTest.xml");
        }

        [SetUp]
        public void Setup()
        {
            _database.PerformDbOperation(DbOperationFlag.CleanInsertIdentity);
        }

        [TestFixtureTearDown]
        public void TestFixtureTearDown()
        {
            //_database.PerformDbOperation(DbOperationFlag.DeleteAll);
        }
    }
}
